package io.github.biezhi.elves.scheduled;

import lombok.extern.slf4j.Slf4j;
import io.github.biezhi.elves.utils.DateUtils;
import io.github.biezhi.elves.spider.BidSpider;
import io.github.biezhi.elves.spider.BiddingInformationNetworkSpider;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 定时解析下载公告内容html数据
 *
 */
@Slf4j
@Configuration
@EnableScheduling
public class ResolveHtmlScheduled {
	@Autowired
	private BidSpider bidSpider;
	@Autowired
	private BiddingInformationNetworkSpider biddingInformationNetworkSpider;
	
	/**
	 * 开始定时解析下载公告内容html数据
	 * 
	 * 每1小时去FTP检测最新的位置区域与客户群关系配置文件
	 */
//	@Scheduled(cron = "*/1 * * * * ?")
//	@Scheduled(cron = "0 0 */1 * * ?")
	public void startResolveHtml() {
		try{
			log.info("=================定时解析公告正文html数据 开始(" + DateUtils.getCurrentDay(DateUtils.dateformat5) + ")===================================");
			
			/**
			 * 解析下载采购公告内容html数据
			 */
//			bidSpider.resolveBiddingHtml("000801");
			
			biddingInformationNetworkSpider.resolveWinBiddingHtml("");
			log.info("=================定时解析公告正文html数据 结束(" + DateUtils.getCurrentDay(DateUtils.dateformat5) + ")===================================");
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}
}